package com.hr.异步调用;

import org.openjdk.jol.info.ClassLayout;

/**
 * @program: leetcode
 * @description: 偏向锁
 * @author: HuRan QQ1345122890
 * @create: 2021-08-16 10:34
 */
public class Demo06 {
    public static void main(String[] args) {
        Dog user = new Dog();
        //jvm延迟偏向锁，所以这时候无锁锁标志 01
        System.out.println("first print" + ClassLayout.parseInstance(user).toPrintable());
        //此时偏向锁关闭，进入同步代码块，变为轻量级锁 00
        synchronized (user) {
            System.out.println("first into sync" + ClassLayout.parseInstance(user).toPrintable());
        }
    }
}

class Dog {

}